package com.tmall.tmall.mapper;

import com.tmall.tmall.pojo.ProductImage;
import com.tmall.tmall.pojo.ProductRt;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface ProductImageMapper {
    @Insert("insert into product_image (pid,type,name) value (#{pid},#{type},#{name})")
    void insert(ProductImage productImage);

    @Select("select name from product_image where delete_at is null and type='img' and pid=#{id}")
    List<String> getByPid(Integer id);

    @Update("update product_image set delete_at = #{time} where pid=#{id} and delete_at is null")
    void deleteByPid(Integer id, LocalDateTime time);
    @Select("select name from product_image where delete_at is null and pid=#{pid} and type='mainImg'")

    String getMainByPid(Integer pid);
}
